package com.console.operations.planmgr;

import com.common.test.OperationBase;
import com.common.test.UITestBase;
import com.console.pages.planmgr.FinancePlanDepositPage;
import com.console.util.FinancePlanDepositUtil;

	/*
	@author 王嘉犇
	@name 钜宝盆后台理财计划代投
	@type 动作类
	 */

public class FinancePlanDeposit extends OperationBase {

	public FinancePlanDeposit(UITestBase tb){
		super(tb);
	}
	
	public boolean isdepositefeecorrected = false;
	
	public void deposit() throws Exception{
		switchToDefaultContent();
		FinancePlanDepositPage fpdp = new FinancePlanDepositPage(tb);
		waitForElementExist(fpdp.panelheaddiv);
		waitForElementDisplayed(fpdp.panelheaddiv);
		fpdp.depositLink.setfindValue("//tr[td[text()='普通_3_20170524001001']]/td[a[text()='投资']]/a");
		waitForElementExist(fpdp.financeplanlastPageNumLnk);
		int pagecount = Integer.parseInt(fpdp.financeplanlastPageNumLnk.getText());
		if(pagecount>1){
			for(int i=1;i<pagecount;i++){
				if(isPresent(fpdp.depositLink)){
					break;
				}else{
					fpdp.pageLink.setfindValue("//li[a[text()='"+ (i+1) +"']]/a");
					fpdp.pageLink.click();
					pause(1000);
				}
			}
			waitForElementDisplayed(fpdp.depositLink);
			fpdp.depositLink.click();
		}else{
			waitForElementDisplayed(fpdp.depositLink);
			fpdp.depositLink.click();
		}
		waitForElementDisplayed(fpdp.cellphoneinput);
		fpdp.cellphoneinput.type(FinancePlanDepositUtil.MOBILE);
		pause(1000);
		fpdp.searchButton.click();
		pause(1000);
		fpdp.amountinput.type(FinancePlanDepositUtil.DEPOSITFEE);
		pause(1000);
		fpdp.assuredepositButton.click();
		pause(1000);
		fpdp.cancelButton.click();
		pause(1000);
	}
}
